<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>登录日志</title>
    <link rel="shortcut icon" type="image/x-icon" th:href="@{/static/img/favicon.ico}" media="screen"/>
    <link rel="stylesheet" th:href="@{/static/css/layui.css}" media="all"/>
</head>
<body>
<form class="layui-form">
    <div class="layui-panel">
        <div style="margin: 15px;">
            <div class="layui-form-item">
                <label class="layui-form-label">登录账号:</label>
                <div class="layui-input-inline">
                    <input type="text" name="userName" id="userName" placeholder="请输入登录账号" lay-affix="clear"
                           class="layui-input">
                </div>
                <div class="layui-input-normal">
                    <button class="layui-btn layui-btn-primary layui-border-green search-btn" lay-submit
                            lay-filter="table-search">
                        <i class="layui-icon layui-icon-search"> </i>查 询
                    </button>
                </div>
            </div>
        </div>
    </div>
    <div class="layui-panel" style="margin-top: 15px;">
        <div class="layui-form nowrap">
            <table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
        </div>
    </div>
</form>
</body>
<script th:src="@{/static/layui.js}"></script>
<script th:replace="~{base::ctx}"/>
<script>
    layui.use(function () {
        const layer = layui.layer;
        const form = layui.form;
        const $ = layui.jquery;
        const table = layui.table;

        table.render({
            elem: '#dataTable',
            url: ctx + 'logManager/getUserLogList',
            toolbar: true,
            defaultToolbar: ['filter', 'exports', 'print'],
            page: true,
            height: '525',
            cols: [
                [
                    {field: 'id', title: 'id', sort: true, fixed: true},
                    {field: 'userName', title: '登录账号', sort: true, fixed: true},
                    {field: 'loginFlag', title: '登录结果', sort: true, fixed: true},
                    {field: 'logIp', title: '登录IP', sort: true, fixed: true},
                    {field: 'logDate', title: '登录时间', sort: true, fixed: true}
                ]
            ],
            parseData: res => parseData(res)
        });

        form.on('submit(table-search)', function (data) {
            const field = data.field;
            table.reloadData('dataTable', {
                scrollPos: true,
                where: field
            });
            return false;
        });
    });
</script>
</html>